<?php
class TestPerson {
    function getPerson() {        
        $fp = fopen("person.txt", "r");
        $contents = fread($fp, filesize("person.txt"));
        fclose($fp);
        $data = explode("|", $contents);
		
		$new_data = array("name" => $data[0], "age" => $data[1], "address" => $data[2]);
        return $new_data;
    }
	
    function savePerson(Array $p){
		$name 		= $p["name"];
		$age 		= $p["age"];
		$address 	= $p["address"];
		$contents = "$name|$age|$address";
		$fp = fopen("person.txt", "w");
		if(fwrite($fp, $contents)){
			fclose($fp);
			return "Data saved";
		};
		return "Error writing data";
    }
}
